Repository navigation
refactor: move the hosting core behind ports and adapters - #103
Merged
Merged
Conversation
The server's hosting policy (which game a host names, the /api/games description, upload and rollback, play counting) was moved out of server.py into src/arcade/hosting/: a core with no I/O, five ports (GameCatalog, VersionStore, PlayCounter, EventReporter, ReleaseNotes), the games.yaml catalog and a null reporter as adapters, and a service that wires the production ones. server.py stays the HTTP adapter. No behaviour was changed: 32 characterization tests pinned the old responses first, and 2,352 generated requests gave identical status, body, headers, stored state, trace events and log lines on the old and new code. Contract, core-on-fakes and architecture tests were added. drafted by Claude on behalf of Daniel Stephenson Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LYNeuk6eJu4dojpaZi8x82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The server's hosting policy was moved out of
server.pyintosrc/arcade/hosting/, without changing behaviour:tests/hosting_fakes.py)GameCataloghosting/adapters/reloading_yaml_catalog.py(wasserver.RegistryHolder, moved nearly verbatim)FakeCatalogVersionStore,PlayCounterstore.Store, unchangedFakeStoreEventReportertrace_client.TraceClient(vendored, untouched), orhosting/adapters/null_reporter.pywhen trace is offRecorderReleaseNotesremote.Remote, unchangedFakeNotescore.HostingholdsgameForHost,describe,addedOf,authorise,checkVersion,deploy,rollbackandplayed. Expected outcomes are values (Denied,Rejected,Deployed) carrying the same status codes and error text as before; the handler maps them to JSON.server.pykeeps HTTP parsing, Content-Length handling, streaming, ranges and ETags.Arcadekeeps its attributes (store,reporter,registry,visits,remote,walks, ...), so callers and existing tests are unchanged.hashTokennow lives inarcade.hosting;__main__imports it from there.How behaviour was held fixed
tests/test_hosting_characterization.py) pin error texts, describe fields, host lookup and play counting. They passed on the old code before anything moved.zoneinfo).tests/test_hosting_contracts.py).tests/test_hosting_architecture.pyfails ifmodel,coreor a port imports an adapter, the service, the server,remoteortrace_client, or if a port or adapter file holds more than one class. It includes a self-test showing the check can fail.core.pyby hand. 5 were killed; the survivor (a nested-label guard ingameForHost) is equivalent, since a slug can't contain a dot.Notes
Logport later.ports/version_store.pyre-exportsVERSION_PATTERN,VersionExistsandNoSuchVersionfromarcade.store, since they are the existing contract.walks, posters) and file streaming were left for a later pass.drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code
https://claude.ai/code/session_01LYNeuk6eJu4dojpaZi8x82